package com.aerozhonghuan.logisticsmall.modules.order.beans;

import android.content.Context;
import android.widget.Toast;

import com.aerozhonghuan.logisticsmall.R;
import com.aerozhonghuan.logisticsmall.modules.order.base.OrderState;
import com.aerozhonghuan.logisticsmall.modules.order.logic.OrderWebRequest;
import com.aerozhonghuan.logisticsmall.widget.CustomDialog;
import com.aerozhonghuan.logisticsmall.widget.ProgressDialogIndicator;
import com.aerozhonghuan.oknet2.CommonCallback;
import com.aerozhonghuan.oknet2.CommonMessage;

/**
 * 描述 待审核状态类
 * @author zhangyonghui
 * 创建日期 2019-05-25
 */
public class WaitReviewState extends OrderState {

    public static final int STATE_WAITREVIEW = 1005;

    public WaitReviewState() {
        this.status = STATE_WAITREVIEW;
        this.name = "待审核";
        this.iconId = R.mipmap.ic_waitreview;
        this.infoDesc = "订单待支付，等待审核";
        this.infoIconId = R.mipmap.ic_waitreview_little;
        this.isHaveActionBtn = true;
        this.actionBtnText = "取消订单";
    }

    @Override
    public CustomDialog getDialog(final Context context, final String billId, final OnDialogListener onDialogListener) {
        final CustomDialog customDialog = new CustomDialog(context, "确认取消此订单?", "取消订单", "暂不取消");
        customDialog.setOnDiaLogListener(new CustomDialog.OnDialogListener() {
            @Override
            public void dialogPositiveListener() {
                final ProgressDialogIndicator progressDialog = new ProgressDialogIndicator(context);
                OrderWebRequest.cancelOrder(context, progressDialog, billId, new CommonCallback<String>() {
                    @Override
                    public void onSuccess(String messsageBodyObject, CommonMessage commonMessage, String allResponseString) {
                        Toast.makeText(context, "取消成功", Toast.LENGTH_SHORT).show();
                        onDialogListener.onSuccess();
                    }
                });
            }

            @Override
            public void dialogNegativeListener() {}
        });
        return customDialog;
    }
}
